/*
 *  sleep-inhibit.h
 *  sleep-inhibit
 *
 *  Created by daadmin on 11/30/10.
 *  Copyright 2010 __MyCompanyName__. All rights reserved.
 *
 */

#define VERSION_MAX 16

#define APP_VERSION			"20101213.1434"


#define APP_NAME			"sleep-inhibit"
#define DEF_REASON			"not_idle"
#define DEF_DISPLAY			":0"
#define DEF_INHIBIT_TIME	 60
#define NAME_MAX			255
#define COOKIE_MAX			 11		//4,294,967,295
#define DISPLAY_MAX			 11

//Types of inhibition..
#define NO_IDLE_SLEEP		0x00000001
#define NO_DISP_SLEEP		0x00000002


//Actions
#define ACT_ACTIONMASK		0x000000FF
#define ACT_INHIBIT			0x00000001
#define ACT_HELP			0x00000002
#define ACT_VERSION			0x00000004


//Options
#define OPT_OPTIONMASK		0x000FF000
#define OPT_QUIET			0x00001000
#define OPT_DEBUG			0x00002000
#define OPT_SAVE			0x00004000
#define OPT_LOG				0x00008000
#define OPT_UTC				0x00010000


#define uchar unsigned char
#define guint uint

typedef struct {
	uint			uOpts;								//Application Options
	uchar			uError;								//exit error code
	uint			uInhibitFlags;						//Type of inhibition
	IOPMAssertionID	uInhibitCookie;						//Inhibit cookie passed from / to gnome session manager
	float			fInhibitDuration;					//Fractional Inhibit duration..
	uchar			cInhibitUnits;						//InhibitDuration Units: s == seconds; m == minutes; h == hours; d == days
	uint			uInhibitSeconds;					//The actual number of seconds to inhibit...
	char			szAppVersion[VERSION_MAX];			//version number
	char			szAppName[NAME_MAX];				//Application name
	char			szAppPath[PATH_MAX+1];				//Application path
	char			szAppID[NAME_MAX];					//Application ID: AppName + UserName
	char			szAppReason[NAME_MAX];				//Reason for inhibiting..
	char			szAppDataFile[PATH_MAX+1];			//cookie file: ~/.appname
	char			szAppLogFile[PATH_MAX+1];			//Log file: default: /var/log/appname.log
	char			szAppDispEnv[DISPLAY_MAX];			//Env var for the display device..
}APPDATA, *LPAPPDATA;


//Return codes:

#define INHIBIT_SUCCESS			0
#define INHIBIT_ERROR			255


//Error Codes:

#define ERROR_NODBUS			100
#define ERROR_NOSESSION 		 99
#define ERROR_CANT_INHIBIT		 90
#define ERROR_CANT_UNINHIBIT	 80
#define ERROR_CANT_READDEFSECS	 70
#define ERROR_CANT_SAVEDEFSECS   60
#define ERROR_CANT_WRITELOG		 50

void DispError (LPAPPDATA lpAppData, char *szFormat, ...);
boolean_t PutDefInhibitSecs (LPAPPDATA lpAppData);



